<template>
	<div class="qopSon zonghe" >
		<common ref='common'></common>
		<div></div>
		<div class="zongheCons">
			近一小时全市面雨量<span class="green">{{jin_Obj.allYu}}</span>。
			最高<span class="green">{{jin_Obj.xianName}}{{jin_Obj.xianMax}}</span>，
			最高乡镇为<span class="green">{{jin_Obj.zhenName}}{{jin_Obj.zhenMax}}</span>，
			最大风力达到<span class="green">{{jin_Obj.windMax}}</span>。
		</div>
		<div class="zongheCons">
			未来一小时全市面雨量<span class="green">{{wei_Obj.allYu}}</span>。
			<span v-show="wei_Obj.xianMax>0">最高{{wei_Obj.xianName}}<span class="green">{{wei_Obj.xianMax}}</span>,</span>	
			<!-- 最高乡镇为{{wei_Obj.zhenName}}<span class="green">{{wei_Obj.zhenMax}}</span>, -->
			<!-- 最大风力达到<span class="green">{{wei_Obj.windMax}}</span>。 -->
		</div>
	</div>
</template>

<script>
import topTitle from './top'
import echarts from 'echarts'
import Vue from 'vue'
import VueModalTor from 'vue-modaltor';
import common from '../common'
Vue.use(VueModalTor);
export default {
    props:["msg"],
	components: {
        topTitle,common,
    },
	data() {
		return {
			title:{
				name: "综合概况",
				time: "",
			},
			jin_Obj:{
				"allYu":0,
				"xianMax":0,
				"zhenMax":0,
				"windMax":0,
				"zhenName":"",
				"xianName":"",
			},
			wei_Obj:{
				"allYu":0,
				"xianMax":0,
				"zhenMax":0,
				"windMax":0,
				"zhenName":"",
				"xianName":"",
			},
		}
	},
	methods:{
		refreshAll(){

		},
		openData(data){
			this.selData=data;
			this.open=true;
		},
		compare2(property){
			return function(a,b){
				var value1 = a[property];
				var value2 = b[property];
				return value2 - value1;
			}
		},
		// 近一小时
        getData(params) {
			var time=this.$refs.common.getthisTime().slice(0,10)+"0000";
			// console.log(time);

			if(time.slice(10,12)<10){
				time=this.$refs.common.getTimeCShow(time,-60);
			}
			// 市面雨量和最大站点雨量
            this.$ajax({method: 'get',	url: "http://10.135.118.52:8080/ZJDataCenter/api/SURF_Wea_Cbf_MUL_HOR/getSurfEleInRegionByTime?userid=aa&pwd=123&dataformat=json&elements=observtimes,PRE,Station_name,TOWN_NAME&times="+time+"&itemlist=R&areacodes=3306&limitCnt=3000",}).then((res)=>{
                var _data=res.data.DS;
				// console.log(_data);
				_data=_data.sort(this.compare2("PRE"));
				this.title.time=_data[0].observtimes;
				var all=0;
				for(var i=0;i<_data.length;i++){
					all+= parseFloat(_data[i].PRE);
				};

				this.jin_Obj["allYu"]=parseFloat(all/_data.length).toFixed(1)+"mm";
				this.jin_Obj["zhenMax"]=parseFloat(_data[0].PRE)+"mm";
				this.jin_Obj["zhenName"]=_data[0].TOWN_NAME;
				// console.log(this.jin_Obj);
            })
            .catch(function(err){
                //console.log(err)
            });
			// 县最高
            this.$ajax({method: 'get',	url: "http://172.21.129.156:8081/web/rain/countSurfaceRainFall",}).then((res)=>{
                var _data=res.data.result;
				// console.log(_data);
				_data=_data.sort(this.compare2("pre1h"));
				this.jin_Obj["xianMax"]=parseFloat(_data[0].pre1h)+"mm";
				this.jin_Obj["xianName"]=_data[0].county+"";
				// console.log(this.jin_Obj);
            })
            .catch(function(err){
                //console.log(err)
			});
			// 最大风
            this.$ajax({method: 'get',	url: "http://10.135.118.52:8080/ZJDataCenter/api/SURF_Wea_Cbf_MUL_HOR/getSurfEleInRegionByTime?userid=aa&pwd=123&dataformat=json&elements=observtimes,WIN_S_Inst_Max,WIN_D_Inst_Max,Station_name,TOWN_NAME,Alti&times="+time+"&itemlist=F&areacodes=3306&limitCnt=3000",}).then((res)=>{
                var _data=res.data.DS;
				// console.log(_data);
				_data=_data.sort(this.compare2("WIN_S_Inst_Max"));
				this.jin_Obj["windMax"]=parseFloat(_data[0].WIN_S_Inst_Max)+"m/s";
				// console.log(this.jin_Obj);
            })
            .catch(function(err){
                //console.log(err)
            });
        },
		// 未来1小时
		getData2(params) {
			var time=this.$refs.common.getthisTime().slice(0,10)+"0000";
			if(time.slice(10,12)<10){
				time=this.$refs.common.getTimeCShow(time,-60);
			}
			// 市面雨量和最大站点雨量
            this.$ajax({method: 'get',	url: "http://10.135.118.52:8080/ZJDataCenter/api/SURF_Wea_Cbf_MUL_HOR/getSurfEleInRegionByTime?userid=aa&pwd=123&dataformat=json&elements=observtimes,PRE,Station_name,TOWN_NAME&times="+time+"&itemlist=R&areacodes=3306&limitCnt=3000",}).then((res)=>{
                var _data=res.data.DS;
				console.log(_data);
				_data=_data.sort(this.compare2("PRE"));
				this.title.time=this.$refs.common.timechangeShow2(_data[0].observtimes);
				var all=0;
				for(var i=0;i<_data.length;i++){
					all+= parseFloat(_data[i].PRE);
				};

				this.wei_Obj["allYu"]=parseFloat(all/_data.length).toFixed(1)+"mm";
				this.wei_Obj["zhenMax"]=parseFloat(_data[0].PRE)+"mm";
				this.wei_Obj["zhenName"]=_data[0].TOWN_NAME;
				console.log(this.wei_Obj);
            })
            .catch(function(err){
                //console.log(err)
            });
			// 县最高
            this.$ajax({method: 'get',	url: "http://172.21.129.156:8081/web/rain/countSurfaceRainFall",}).then((res)=>{
                var _data=res.data.result;
				console.log(_data);
				

				_data=_data.sort(this.compare2("fore1h"));
				if(_data[0].fore1h||_data[0].fore1h==0){
					this.wei_Obj["xianMax"]=parseFloat(_data[0].fore1h)+"mm";
				}
				console.log(_data[0].fore1h);
				this.wei_Obj["xianName"]=_data[0].county+"";
				console.log(this.wei_Obj.xianName);

            })
            .catch(function(err){
                //console.log(err)
			});
			// 最大风
            this.$ajax({method: 'get',	url: "http://10.135.118.52:8080/ZJDataCenter/api/SURF_Wea_Cbf_MUL_HOR/getSurfEleInRegionByTime?userid=aa&pwd=123&dataformat=json&elements=observtimes,WIN_S_Inst_Max,WIN_D_Inst_Max,Station_name,TOWN_NAME,Alti&times="+time+"&itemlist=F&areacodes=3306&limitCnt=3000",}).then((res)=>{
                var _data=res.data.DS;
				console.log(_data);
				_data=_data.sort(this.compare2("WIN_S_Inst_Max"));
				this.wei_Obj["windMax"]=parseFloat(_data[0].WIN_S_Inst_Max)+"m/s";
				console.log(this.wei_Obj);
            })
            .catch(function(err){
                //console.log(err)
            });
        }
		
    },
	mounted(){
        this.$emit('refreshTop',this.title);
        this.getData();
        this.getData2();
	}
}
</script>

<style lang="less">
.qopSon{
	height: 384px !important;
}
	.zonghe{
		height: 350px;
		.zongheCons{
			padding: 10px 15px;
			font-size: 15px;
		}
		.green{
			color: #6ECF93;
		}
	}
</style>
